<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
</head>
<body>
 <form>
     <div>
         用户名：<input type="text" id="username"/>
     </div>
     <div>
         密码：<input type="text" id="password"/>
     </div>
     <div>
         <button type="button" id="btnLogin">登录</button>
     </div>

 </form>
</body>
<script src="lib/jquery.js"></script>
<script>
    $('#btnLogin').bind('click',function () {
        $.ajax({
                url:'http://localhost:3000/user/login',
                method:'get', // 或者post
                dataType:'json',
                data:{
                    username:$('#username').val(),
                    password:$('#password').val()
                },
                success:function (data) {
                    console.log(data);
                    if(data.flag){
                        window.location.href="index.html"
                    }else {
                        alert("用户名或者密码错误！！")
                    }
                }
        })
    })
</script>
</html>
